#include "Widget.h"
#include "ui_Widget.h"
#include"gamecontrol.h"

Widget* Widget::widget=nullptr;

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);


    this->setFixedSize(1024,1024);
    widget =this;


}

Widget::~Widget()
{
    delete ui;
}


void Widget::keyPressEvent(QKeyEvent *event)
{
    //添加对应按键组合
    switch (event->key())
    {
    case   Qt::Key_A:
    case   Qt::Key_D:
    GameControl::Instanse()->mKeyList.append(event->key());
    break;
    }
}

void Widget::keyReleaseEvent(QKeyEvent *event)
{
    //移除对应按键组合
    if(GameControl::Instanse()->mKeyList.contains(event->key()))
    {
        GameControl::Instanse()->mKeyList.removeOne(event->key());
    }
}


